1 /*
2  * This file is part of gtkD.
3  *
4  * gtkD is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License
6  * as published by the Free Software Foundation; either version 3
7  * of the License, or (at your option) any later version, with
8  * some exceptions, please read the COPYING file.
9  *
10  * gtkD is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with gtkD; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
18  */
19 
20 // generated automatically - do not change
21 // find conversion definition on APILookup.txt
22 // implement new conversion functionalities on the wrap.utils pakage
23 
24 
25 module soup.Session;
26 
27 private import gio.AsyncResultIF;
28 private import gio.Cancellable;
29 private import gio.IOStream;
30 private import gio.InputStream;
31 private import glib.ConstructionException;
32 private import glib.ErrorG;
33 private import glib.GException;
34 private import glib.ListSG;
35 private import glib.MainContext;
36 private import glib.Str;
37 private import gobject.ObjectG;
38 private import gobject.Signals;
39 private import soup.Auth;
40 private import soup.Message;
41 private import soup.Request;
42 private import soup.RequestHTTP;
43 private import soup.SSocket;
44 private import soup.SessionFeatureIF;
45 private import soup.URI;
46 private import soup.WebsocketConnection;
47 private import soup.c.functions;
48 public  import soup.c.types;
49 private import std.algorithm;
50 
51 
52 /** */
53 public class Session : ObjectG
54 {
55 	/** the main Gtk struct */
56 	protected SoupSession* soupSession;
57 
58 	/** Get the main Gtk struct */
59 	public SoupSession* getSessionStruct(bool transferOwnership = false)
60 	{
61 		if (transferOwnership)
62 			ownedRef = false;
63 		return soupSession;
64 	}
65 
66 	/** the main Gtk struct as a void* */
67 	protected override void* getStruct()
68 	{
69 		return cast(void*)soupSession;
70 	}
71 
72 	/**
73 	 * Sets our main struct and passes it to the parent class.
74 	 */
75 	public this (SoupSession* soupSession, bool ownedRef = false)
76 	{
77 		this.soupSession = soupSession;
78 		super(cast(GObject*)soupSession, ownedRef);
79 	}
80 
81 
82 	/** */
83 	public static GType getType()
84 	{
85 		return soup_session_get_type();
86 	}
87 
88 	/**
89 	 * Creates a #SoupSession with the default options.
90 	 *
91 	 * Returns: the new session.
92 	 *
93 	 * Since: 2.42
94 	 *
95 	 * Throws: ConstructionException GTK+ fails to create the object.
96 	 */
97 	public this()
98 	{
99 		auto __p = soup_session_new();
100 
101 		if(__p is null)
102 		{
103 			throw new ConstructionException("null returned by new");
104 		}
105 
106 		this(cast(SoupSession*) __p, true);
107 	}
108 
109 	/**
110 	 * Cancels all pending requests in @session and closes all idle
111 	 * persistent connections.
112 	 *
113 	 * The message cancellation has the same semantics as with
114 	 * soup_session_cancel_message(); asynchronous requests on a
115 	 * #SoupSessionAsync will have their callback called before
116 	 * soup_session_abort() returns. Requests on a plain #SoupSession will
117 	 * not.
118 	 */
119 	public void abort()
120 	{
121 		soup_session_abort(soupSession);
122 	}
123 
124 	/**
125 	 * Adds @feature's functionality to @session. You can also add a
126 	 * feature to the session at construct time by using the
127 	 * %SOUP_SESSION_ADD_FEATURE property.
128 	 *
129 	 * See the main #SoupSession documentation for information on what
130 	 * features are present in sessions by default.
131 	 *
132 	 * Params:
133 	 *     feature = an object that implements #SoupSessionFeature
134 	 *
135 	 * Since: 2.24
136 	 */
137 	public void addFeature(SessionFeatureIF feature)
138 	{
139 		soup_session_add_feature(soupSession, (feature is null) ? null : feature.getSessionFeatureStruct());
140 	}
141 
142 	/**
143 	 * If @feature_type is the type of a class that implements
144 	 * #SoupSessionFeature, this creates a new feature of that type and
145 	 * adds it to @session as with soup_session_add_feature(). You can use
146 	 * this when you don't need to customize the new feature in any way.
147 	 *
148 	 * If @feature_type is not a #SoupSessionFeature type, this gives each
149 	 * existing feature on @session the chance to accept @feature_type as
150 	 * a "subfeature". This can be used to add new #SoupAuth or
151 	 * #SoupRequest types, for instance.
152 	 *
153 	 * You can also add a feature to the session at construct time by
154 	 * using the %SOUP_SESSION_ADD_FEATURE_BY_TYPE property.
155 	 *
156 	 * See the main #SoupSession documentation for information on what
157 	 * features are present in sessions by default.
158 	 *
159 	 * Params:
160 	 *     featureType = a #GType
161 	 *
162 	 * Since: 2.24
163 	 */
164 	public void addFeatureByType(GType featureType)
165 	{
166 		soup_session_add_feature_by_type(soupSession, featureType);
167 	}
168 
169 	/**
170 	 * Causes @session to immediately finish processing @msg (regardless
171 	 * of its current state) with a final status_code of @status_code. You
172 	 * may call this at any time after handing @msg off to @session; if
173 	 * @session has started sending the request but has not yet received
174 	 * the complete response, then it will close the request's connection.
175 	 * Note that with requests that have side effects (eg,
176 	 * <literal>POST</literal>, <literal>PUT</literal>,
177 	 * <literal>DELETE</literal>) it is possible that you might cancel the
178 	 * request after the server acts on it, but before it returns a
179 	 * response, leaving the remote resource in an unknown state.
180 	 *
181 	 * If the message is cancelled while its response body is being read,
182 	 * then the response body in @msg will be left partially-filled-in.
183 	 * The response headers, on the other hand, will always be either
184 	 * empty or complete.
185 	 *
186 	 * Beware that with the deprecated #SoupSessionAsync, messages queued
187 	 * with soup_session_queue_message() will have their callbacks invoked
188 	 * before soup_session_cancel_message() returns. The plain
189 	 * #SoupSession does not have this behavior; cancelling an
190 	 * asynchronous message will merely queue its callback to be run after
191 	 * returning to the main loop.
192 	 *
193 	 * Params:
194 	 *     msg = the message to cancel
195 	 *     statusCode = status code to set on @msg (generally
196 	 *         %SOUP_STATUS_CANCELLED)
197 	 */
198 	public void cancelMessage(Message msg, uint statusCode)
199 	{
200 		soup_session_cancel_message(soupSession, (msg is null) ? null : msg.getMessageStruct(), statusCode);
201 	}
202 
203 	/**
204 	 * Start a connection to @uri. The operation can be monitored by providing a @progress_callback
205 	 * and finishes when the connection is done or an error ocurred.
206 	 *
207 	 * Call soup_session_connect_finish() to get the #GIOStream to communicate with the server.
208 	 *
209 	 * Params:
210 	 *     uri = a #SoupURI to connect to
211 	 *     cancellable = a #GCancellable
212 	 *     progressCallback = a #SoupSessionConnectProgressCallback which
213 	 *         will be called for every network event that occurs during the connection.
214 	 *     callback = the callback to invoke when the operation finishes
215 	 *     userData = data for @progress_callback and @callback
216 	 *
217 	 * Since: 2.62
218 	 */
219 	public void connectAsync(URI uri, Cancellable cancellable, SoupSessionConnectProgressCallback progressCallback, GAsyncReadyCallback callback, void* userData)
220 	{
221 		soup_session_connect_async(soupSession, (uri is null) ? null : uri.getURIStruct(), (cancellable is null) ? null : cancellable.getCancellableStruct(), progressCallback, callback, userData);
222 	}
223 
224 	/**
225 	 * Gets the #GIOStream created for the connection to communicate with the server.
226 	 *
227 	 * Params:
228 	 *     result = the #GAsyncResult passed to your callback
229 	 *
230 	 * Returns: a new #GIOStream, or %NULL on error.
231 	 *
232 	 * Since: 2.62
233 	 *
234 	 * Throws: GException on failure.
235 	 */
236 	public IOStream connectFinish(AsyncResultIF result)
237 	{
238 		GError* err = null;
239 
240 		auto __p = soup_session_connect_finish(soupSession, (result is null) ? null : result.getAsyncResultStruct(), &err);
241 
242 		if (err !is null)
243 		{
244 			throw new GException( new ErrorG(err) );
245 		}
246 
247 		if(__p is null)
248 		{
249 			return null;
250 		}
251 
252 		return ObjectG.getDObject!(IOStream)(cast(GIOStream*) __p, true);
253 	}
254 
255 	/**
256 	 * Gets @session's #SoupSession:async-context. This does not add a ref
257 	 * to the context, so you will need to ref it yourself if you want it
258 	 * to outlive its session.
259 	 *
260 	 * For a modern #SoupSession, this will always just return the
261 	 * thread-default #GMainContext, and so is not especially useful.
262 	 *
263 	 * Returns: @session's #GMainContext,
264 	 *     which may be %NULL
265 	 */
266 	public MainContext getAsyncContext()
267 	{
268 		auto __p = soup_session_get_async_context(soupSession);
269 
270 		if(__p is null)
271 		{
272 			return null;
273 		}
274 
275 		return new MainContext(cast(GMainContext*) __p);
276 	}
277 
278 	/**
279 	 * Gets the first feature in @session of type @feature_type. For
280 	 * features where there may be more than one feature of a given type,
281 	 * use soup_session_get_features().
282 	 *
283 	 * Params:
284 	 *     featureType = the #GType of the feature to get
285 	 *
286 	 * Returns: a #SoupSessionFeature, or
287 	 *     %NULL. The feature is owned by @session.
288 	 *
289 	 * Since: 2.26
290 	 */
291 	public SessionFeatureIF getFeature(GType featureType)
292 	{
293 		auto __p = soup_session_get_feature(soupSession, featureType);
294 
295 		if(__p is null)
296 		{
297 			return null;
298 		}
299 
300 		return ObjectG.getDObject!(SessionFeatureIF)(cast(SoupSessionFeature*) __p);
301 	}
302 
303 	/**
304 	 * Gets the first feature in @session of type @feature_type, provided
305 	 * that it is not disabled for @msg. As with
306 	 * soup_session_get_feature(), this should only be used for features
307 	 * where @feature_type is only expected to match a single feature. In
308 	 * particular, if there are two matching features, and the first is
309 	 * disabled on @msg, and the second is not, then this will return
310 	 * %NULL, not the second feature.
311 	 *
312 	 * Params:
313 	 *     featureType = the #GType of the feature to get
314 	 *     msg = a #SoupMessage
315 	 *
316 	 * Returns: a #SoupSessionFeature, or %NULL. The
317 	 *     feature is owned by @session.
318 	 *
319 	 * Since: 2.28
320 	 */
321 	public SessionFeatureIF getFeatureForMessage(GType featureType, Message msg)
322 	{
323 		auto __p = soup_session_get_feature_for_message(soupSession, featureType, (msg is null) ? null : msg.getMessageStruct());
324 
325 		if(__p is null)
326 		{
327 			return null;
328 		}
329 
330 		return ObjectG.getDObject!(SessionFeatureIF)(cast(SoupSessionFeature*) __p);
331 	}
332 
333 	/**
334 	 * Generates a list of @session's features of type @feature_type. (If
335 	 * you want to see all features, you can pass %SOUP_TYPE_SESSION_FEATURE
336 	 * for @feature_type.)
337 	 *
338 	 * Params:
339 	 *     featureType = the #GType of the class of features to get
340 	 *
341 	 * Returns: a list of features. You must free the list, but not its contents
342 	 *
343 	 * Since: 2.26
344 	 */
345 	public ListSG getFeatures(GType featureType)
346 	{
347 		auto __p = soup_session_get_features(soupSession, featureType);
348 
349 		if(__p is null)
350 		{
351 			return null;
352 		}
353 
354 		return new ListSG(cast(GSList*) __p);
355 	}
356 
357 	/**
358 	 * Tests if @session has at a feature of type @feature_type (which can
359 	 * be the type of either a #SoupSessionFeature, or else a subtype of
360 	 * some class managed by another feature, such as #SoupAuth or
361 	 * #SoupRequest).
362 	 *
363 	 * Params:
364 	 *     featureType = the #GType of the class of features to check for
365 	 *
366 	 * Returns: %TRUE or %FALSE
367 	 *
368 	 * Since: 2.42
369 	 */
370 	public bool hasFeature(GType featureType)
371 	{
372 		return soup_session_has_feature(soupSession, featureType) != 0;
373 	}
374 
375 	/**
376 	 * Pauses HTTP I/O on @msg. Call soup_session_unpause_message() to
377 	 * resume I/O.
378 	 *
379 	 * This may only be called for asynchronous messages (those sent on a
380 	 * #SoupSessionAsync or using soup_session_queue_message()).
381 	 *
382 	 * Params:
383 	 *     msg = a #SoupMessage currently running on @session
384 	 */
385 	public void pauseMessage(Message msg)
386 	{
387 		soup_session_pause_message(soupSession, (msg is null) ? null : msg.getMessageStruct());
388 	}
389 
390 	/**
391 	 * Tells @session that an URI from the given @hostname may be requested
392 	 * shortly, and so the session can try to prepare by resolving the
393 	 * domain name in advance, in order to work more quickly once the URI
394 	 * is actually requested.
395 	 *
396 	 * If @cancellable is non-%NULL, it can be used to cancel the
397 	 * resolution. @callback will still be invoked in this case, with a
398 	 * status of %SOUP_STATUS_CANCELLED.
399 	 *
400 	 * Params:
401 	 *     hostname = a hostname to be resolved
402 	 *     cancellable = a #GCancellable object, or %NULL
403 	 *     callback = callback to call with the
404 	 *         result, or %NULL
405 	 *     userData = data for @callback
406 	 *
407 	 * Since: 2.38
408 	 */
409 	public void prefetchDns(string hostname, Cancellable cancellable, SoupAddressCallback callback, void* userData)
410 	{
411 		soup_session_prefetch_dns(soupSession, Str.toStringz(hostname), (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData);
412 	}
413 
414 	/**
415 	 * Tells @session that @uri may be requested shortly, and so the
416 	 * session can try to prepare (resolving the domain name, obtaining
417 	 * proxy address, etc.) in order to work more quickly once the URI is
418 	 * actually requested.
419 	 *
420 	 * Deprecated: use soup_session_prefetch_dns() instead
421 	 *
422 	 * Params:
423 	 *     uri = a #SoupURI which may be required
424 	 *
425 	 * Since: 2.30
426 	 */
427 	public void prepareForUri(URI uri)
428 	{
429 		soup_session_prepare_for_uri(soupSession, (uri is null) ? null : uri.getURIStruct());
430 	}
431 
432 	/**
433 	 * Queues the message @msg for asynchronously sending the request and
434 	 * receiving a response in the current thread-default #GMainContext.
435 	 * If @msg has been processed before, any resources related to the
436 	 * time it was last sent are freed.
437 	 *
438 	 * Upon message completion, the callback specified in @callback will
439 	 * be invoked. If after returning from this callback the message has not
440 	 * been requeued, @msg will be unreffed.
441 	 *
442 	 * (The behavior above applies to a plain #SoupSession; if you are
443 	 * using #SoupSessionAsync or #SoupSessionSync, then the #GMainContext
444 	 * that is used depends on the settings of #SoupSession:async-context
445 	 * and #SoupSession:use-thread-context, and for #SoupSessionSync, the
446 	 * message will actually be sent and processed in another thread, with
447 	 * only the final callback occurring in the indicated #GMainContext.)
448 	 *
449 	 * Contrast this method with soup_session_send_async(), which also
450 	 * asynchronously sends a message, but returns before reading the
451 	 * response body, and allows you to read the response via a
452 	 * #GInputStream.
453 	 *
454 	 * Params:
455 	 *     msg = the message to queue
456 	 *     callback = a #SoupSessionCallback which will
457 	 *         be called after the message completes or when an unrecoverable error occurs.
458 	 *     userData = a pointer passed to @callback.
459 	 */
460 	public void queueMessage(Message msg, SoupSessionCallback callback, void* userData)
461 	{
462 		soup_session_queue_message(soupSession, (msg is null) ? null : msg.getMessageStruct(), callback, userData);
463 	}
464 
465 	/**
466 	 * Updates @msg's URI according to its status code and "Location"
467 	 * header, and requeues it on @session. Use this when you have set
468 	 * %SOUP_MESSAGE_NO_REDIRECT on a message, but have decided to allow a
469 	 * particular redirection to occur, or if you want to allow a
470 	 * redirection that #SoupSession will not perform automatically (eg,
471 	 * redirecting a non-safe method such as DELETE).
472 	 *
473 	 * If @msg's status code indicates that it should be retried as a GET
474 	 * request, then @msg will be modified accordingly.
475 	 *
476 	 * If @msg has already been redirected too many times, this will
477 	 * cause it to fail with %SOUP_STATUS_TOO_MANY_REDIRECTS.
478 	 *
479 	 * Params:
480 	 *     msg = a #SoupMessage that has received a 3xx response
481 	 *
482 	 * Returns: %TRUE if a redirection was applied, %FALSE if not
483 	 *     (eg, because there was no Location header, or it could not be
484 	 *     parsed).
485 	 *
486 	 * Since: 2.38
487 	 */
488 	public bool redirectMessage(Message msg)
489 	{
490 		return soup_session_redirect_message(soupSession, (msg is null) ? null : msg.getMessageStruct()) != 0;
491 	}
492 
493 	/**
494 	 * Removes @feature's functionality from @session.
495 	 *
496 	 * Params:
497 	 *     feature = a feature that has previously been added to @session
498 	 *
499 	 * Since: 2.24
500 	 */
501 	public void removeFeature(SessionFeatureIF feature)
502 	{
503 		soup_session_remove_feature(soupSession, (feature is null) ? null : feature.getSessionFeatureStruct());
504 	}
505 
506 	/**
507 	 * Removes all features of type @feature_type (or any subclass of
508 	 * @feature_type) from @session. You can also remove standard features
509 	 * from the session at construct time by using the
510 	 * %SOUP_SESSION_REMOVE_FEATURE_BY_TYPE property.
511 	 *
512 	 * Params:
513 	 *     featureType = a #GType
514 	 *
515 	 * Since: 2.24
516 	 */
517 	public void removeFeatureByType(GType featureType)
518 	{
519 		soup_session_remove_feature_by_type(soupSession, featureType);
520 	}
521 
522 	/**
523 	 * Creates a #SoupRequest for retrieving @uri_string.
524 	 *
525 	 * Params:
526 	 *     uriString = a URI, in string form
527 	 *
528 	 * Returns: a new #SoupRequest, or
529 	 *     %NULL on error.
530 	 *
531 	 * Since: 2.42
532 	 *
533 	 * Throws: GException on failure.
534 	 */
535 	public Request request(string uriString)
536 	{
537 		GError* err = null;
538 
539 		auto __p = soup_session_request(soupSession, Str.toStringz(uriString), &err);
540 
541 		if (err !is null)
542 		{
543 			throw new GException( new ErrorG(err) );
544 		}
545 
546 		if(__p is null)
547 		{
548 			return null;
549 		}
550 
551 		return ObjectG.getDObject!(Request)(cast(SoupRequest*) __p, true);
552 	}
553 
554 	/**
555 	 * Creates a #SoupRequest for retrieving @uri_string, which must be an
556 	 * "http" or "https" URI (or another protocol listed in @session's
557 	 * #SoupSession:http-aliases or #SoupSession:https-aliases).
558 	 *
559 	 * Params:
560 	 *     method = an HTTP method
561 	 *     uriString = a URI, in string form
562 	 *
563 	 * Returns: a new #SoupRequestHTTP, or
564 	 *     %NULL on error.
565 	 *
566 	 * Since: 2.42
567 	 *
568 	 * Throws: GException on failure.
569 	 */
570 	public RequestHTTP requestHttp(string method, string uriString)
571 	{
572 		GError* err = null;
573 
574 		auto __p = soup_session_request_http(soupSession, Str.toStringz(method), Str.toStringz(uriString), &err);
575 
576 		if (err !is null)
577 		{
578 			throw new GException( new ErrorG(err) );
579 		}
580 
581 		if(__p is null)
582 		{
583 			return null;
584 		}
585 
586 		return ObjectG.getDObject!(RequestHTTP)(cast(SoupRequestHTTP*) __p, true);
587 	}
588 
589 	/**
590 	 * Creates a #SoupRequest for retrieving @uri, which must be an
591 	 * "http" or "https" URI (or another protocol listed in @session's
592 	 * #SoupSession:http-aliases or #SoupSession:https-aliases).
593 	 *
594 	 * Params:
595 	 *     method = an HTTP method
596 	 *     uri = a #SoupURI representing the URI to retrieve
597 	 *
598 	 * Returns: a new #SoupRequestHTTP, or
599 	 *     %NULL on error.
600 	 *
601 	 * Since: 2.42
602 	 *
603 	 * Throws: GException on failure.
604 	 */
605 	public RequestHTTP requestHttpUri(string method, URI uri)
606 	{
607 		GError* err = null;
608 
609 		auto __p = soup_session_request_http_uri(soupSession, Str.toStringz(method), (uri is null) ? null : uri.getURIStruct(), &err);
610 
611 		if (err !is null)
612 		{
613 			throw new GException( new ErrorG(err) );
614 		}
615 
616 		if(__p is null)
617 		{
618 			return null;
619 		}
620 
621 		return ObjectG.getDObject!(RequestHTTP)(cast(SoupRequestHTTP*) __p, true);
622 	}
623 
624 	/**
625 	 * Creates a #SoupRequest for retrieving @uri.
626 	 *
627 	 * Params:
628 	 *     uri = a #SoupURI representing the URI to retrieve
629 	 *
630 	 * Returns: a new #SoupRequest, or
631 	 *     %NULL on error.
632 	 *
633 	 * Since: 2.42
634 	 *
635 	 * Throws: GException on failure.
636 	 */
637 	public Request requestUri(URI uri)
638 	{
639 		GError* err = null;
640 
641 		auto __p = soup_session_request_uri(soupSession, (uri is null) ? null : uri.getURIStruct(), &err);
642 
643 		if (err !is null)
644 		{
645 			throw new GException( new ErrorG(err) );
646 		}
647 
648 		if(__p is null)
649 		{
650 			return null;
651 		}
652 
653 		return ObjectG.getDObject!(Request)(cast(SoupRequest*) __p, true);
654 	}
655 
656 	/**
657 	 * This causes @msg to be placed back on the queue to be attempted
658 	 * again.
659 	 *
660 	 * Params:
661 	 *     msg = the message to requeue
662 	 */
663 	public void requeueMessage(Message msg)
664 	{
665 		soup_session_requeue_message(soupSession, (msg is null) ? null : msg.getMessageStruct());
666 	}
667 
668 	/**
669 	 * Synchronously sends @msg and waits for the beginning of a response.
670 	 * On success, a #GInputStream will be returned which you can use to
671 	 * read the response body. ("Success" here means only that an HTTP
672 	 * response was received and understood; it does not necessarily mean
673 	 * that a 2xx class status code was received.)
674 	 *
675 	 * If non-%NULL, @cancellable can be used to cancel the request;
676 	 * soup_session_send() will return a %G_IO_ERROR_CANCELLED error. Note
677 	 * that with requests that have side effects (eg,
678 	 * <literal>POST</literal>, <literal>PUT</literal>,
679 	 * <literal>DELETE</literal>) it is possible that you might cancel the
680 	 * request after the server acts on it, but before it returns a
681 	 * response, leaving the remote resource in an unknown state.
682 	 *
683 	 * If @msg is requeued due to a redirect or authentication, the
684 	 * initial (3xx/401/407) response body will be suppressed, and
685 	 * soup_session_send() will only return once a final response has been
686 	 * received.
687 	 *
688 	 * Contrast this method with soup_session_send_message(), which also
689 	 * synchronously sends a #SoupMessage, but doesn't return until the
690 	 * response has been completely read.
691 	 *
692 	 * (Note that this method cannot be called on the deprecated
693 	 * #SoupSessionAsync subclass.)
694 	 *
695 	 * Params:
696 	 *     msg = a #SoupMessage
697 	 *     cancellable = a #GCancellable
698 	 *
699 	 * Returns: a #GInputStream for reading the
700 	 *     response body, or %NULL on error.
701 	 *
702 	 * Since: 2.42
703 	 *
704 	 * Throws: GException on failure.
705 	 */
706 	public InputStream send(Message msg, Cancellable cancellable)
707 	{
708 		GError* err = null;
709 
710 		auto __p = soup_session_send(soupSession, (msg is null) ? null : msg.getMessageStruct(), (cancellable is null) ? null : cancellable.getCancellableStruct(), &err);
711 
712 		if (err !is null)
713 		{
714 			throw new GException( new ErrorG(err) );
715 		}
716 
717 		if(__p is null)
718 		{
719 			return null;
720 		}
721 
722 		return ObjectG.getDObject!(InputStream)(cast(GInputStream*) __p, true);
723 	}
724 
725 	/**
726 	 * Asynchronously sends @msg and waits for the beginning of a
727 	 * response. When @callback is called, then either @msg has been sent,
728 	 * and its response headers received, or else an error has occurred.
729 	 * Call soup_session_send_finish() to get a #GInputStream for reading
730 	 * the response body.
731 	 *
732 	 * See soup_session_send() for more details on the general semantics.
733 	 *
734 	 * Contrast this method with soup_session_queue_message(), which also
735 	 * asynchronously sends a #SoupMessage, but doesn't invoke its
736 	 * callback until the response has been completely read.
737 	 *
738 	 * (Note that this method cannot be called on the deprecated
739 	 * #SoupSessionSync subclass, and can only be called on
740 	 * #SoupSessionAsync if you have set the
741 	 * #SoupSession:use-thread-context property.)
742 	 *
743 	 * Params:
744 	 *     msg = a #SoupMessage
745 	 *     cancellable = a #GCancellable
746 	 *     callback = the callback to invoke
747 	 *     userData = data for @callback
748 	 *
749 	 * Since: 2.42
750 	 */
751 	public void sendAsync(Message msg, Cancellable cancellable, GAsyncReadyCallback callback, void* userData)
752 	{
753 		soup_session_send_async(soupSession, (msg is null) ? null : msg.getMessageStruct(), (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData);
754 	}
755 
756 	/**
757 	 * Gets the response to a soup_session_send_async() call and (if
758 	 * successful), returns a #GInputStream that can be used to read the
759 	 * response body.
760 	 *
761 	 * Params:
762 	 *     result = the #GAsyncResult passed to your callback
763 	 *
764 	 * Returns: a #GInputStream for reading the
765 	 *     response body, or %NULL on error.
766 	 *
767 	 * Since: 2.42
768 	 *
769 	 * Throws: GException on failure.
770 	 */
771 	public InputStream sendFinish(AsyncResultIF result)
772 	{
773 		GError* err = null;
774 
775 		auto __p = soup_session_send_finish(soupSession, (result is null) ? null : result.getAsyncResultStruct(), &err);
776 
777 		if (err !is null)
778 		{
779 			throw new GException( new ErrorG(err) );
780 		}
781 
782 		if(__p is null)
783 		{
784 			return null;
785 		}
786 
787 		return ObjectG.getDObject!(InputStream)(cast(GInputStream*) __p, true);
788 	}
789 
790 	/**
791 	 * Synchronously send @msg. This call will not return until the
792 	 * transfer is finished successfully or there is an unrecoverable
793 	 * error.
794 	 *
795 	 * Unlike with soup_session_queue_message(), @msg is not freed upon
796 	 * return.
797 	 *
798 	 * (Note that if you call this method on a #SoupSessionAsync, it will
799 	 * still use asynchronous I/O internally, running the glib main loop
800 	 * to process the message, which may also cause other events to be
801 	 * processed.)
802 	 *
803 	 * Contrast this method with soup_session_send(), which also
804 	 * synchronously sends a message, but returns before reading the
805 	 * response body, and allows you to read the response via a
806 	 * #GInputStream.
807 	 *
808 	 * Params:
809 	 *     msg = the message to send
810 	 *
811 	 * Returns: the HTTP status code of the response
812 	 */
813 	public uint sendMessage(Message msg)
814 	{
815 		return soup_session_send_message(soupSession, (msg is null) ? null : msg.getMessageStruct());
816 	}
817 
818 	/**
819 	 * "Steals" the HTTP connection associated with @msg from @session.
820 	 * This happens immediately, regardless of the current state of the
821 	 * connection, and @msg's callback will not be called. You can steal
822 	 * the connection from a #SoupMessage signal handler if you need to
823 	 * wait for part or all of the response to be received first.
824 	 *
825 	 * Calling this function may cause @msg to be freed if you are not
826 	 * holding any other reference to it.
827 	 *
828 	 * Params:
829 	 *     msg = the message whose connection is to be stolen
830 	 *
831 	 * Returns: the #GIOStream formerly associated
832 	 *     with @msg (or %NULL if @msg was no longer associated with a
833 	 *     connection). No guarantees are made about what kind of #GIOStream
834 	 *     is returned.
835 	 *
836 	 * Since: 2.50
837 	 */
838 	public IOStream stealConnection(Message msg)
839 	{
840 		auto __p = soup_session_steal_connection(soupSession, (msg is null) ? null : msg.getMessageStruct());
841 
842 		if(__p is null)
843 		{
844 			return null;
845 		}
846 
847 		return ObjectG.getDObject!(IOStream)(cast(GIOStream*) __p, true);
848 	}
849 
850 	/**
851 	 * Resumes HTTP I/O on @msg. Use this to resume after calling
852 	 * soup_session_pause_message().
853 	 *
854 	 * If @msg is being sent via blocking I/O, this will resume reading or
855 	 * writing immediately. If @msg is using non-blocking I/O, then
856 	 * reading or writing won't resume until you return to the main loop.
857 	 *
858 	 * This may only be called for asynchronous messages (those sent on a
859 	 * #SoupSessionAsync or using soup_session_queue_message()).
860 	 *
861 	 * Params:
862 	 *     msg = a #SoupMessage currently running on @session
863 	 */
864 	public void unpauseMessage(Message msg)
865 	{
866 		soup_session_unpause_message(soupSession, (msg is null) ? null : msg.getMessageStruct());
867 	}
868 
869 	/**
870 	 * Asynchronously creates a #SoupWebsocketConnection to communicate
871 	 * with a remote server.
872 	 *
873 	 * All necessary WebSocket-related headers will be added to @msg, and
874 	 * it will then be sent and asynchronously processed normally
875 	 * (including handling of redirection and HTTP authentication).
876 	 *
877 	 * If the server returns "101 Switching Protocols", then @msg's status
878 	 * code and response headers will be updated, and then the WebSocket
879 	 * handshake will be completed. On success,
880 	 * soup_session_websocket_connect_finish() will return a new
881 	 * #SoupWebsocketConnection. On failure it will return a #GError.
882 	 *
883 	 * If the server returns a status other than "101 Switching
884 	 * Protocols", then @msg will contain the complete response headers
885 	 * and body from the server's response, and
886 	 * soup_session_websocket_connect_finish() will return
887 	 * %SOUP_WEBSOCKET_ERROR_NOT_WEBSOCKET.
888 	 *
889 	 * Params:
890 	 *     msg = #SoupMessage indicating the WebSocket server to connect to
891 	 *     origin = origin of the connection
892 	 *     protocols = a
893 	 *         %NULL-terminated array of protocols supported
894 	 *     cancellable = a #GCancellable
895 	 *     callback = the callback to invoke
896 	 *     userData = data for @callback
897 	 *
898 	 * Since: 2.50
899 	 */
900 	public void websocketConnectAsync(Message msg, string origin, string[] protocols, Cancellable cancellable, GAsyncReadyCallback callback, void* userData)
901 	{
902 		soup_session_websocket_connect_async(soupSession, (msg is null) ? null : msg.getMessageStruct(), Str.toStringz(origin), Str.toStringzArray(protocols), (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData);
903 	}
904 
905 	/**
906 	 * Gets the #SoupWebsocketConnection response to a
907 	 * soup_session_websocket_connect_async() call and (if successful),
908 	 * returns a #SoupWebsocketConnection that can be used to communicate
909 	 * with the server.
910 	 *
911 	 * Params:
912 	 *     result = the #GAsyncResult passed to your callback
913 	 *
914 	 * Returns: a new #SoupWebsocketConnection, or
915 	 *     %NULL on error.
916 	 *
917 	 * Since: 2.50
918 	 *
919 	 * Throws: GException on failure.
920 	 */
921 	public WebsocketConnection websocketConnectFinish(AsyncResultIF result)
922 	{
923 		GError* err = null;
924 
925 		auto __p = soup_session_websocket_connect_finish(soupSession, (result is null) ? null : result.getAsyncResultStruct(), &err);
926 
927 		if (err !is null)
928 		{
929 			throw new GException( new ErrorG(err) );
930 		}
931 
932 		if(__p is null)
933 		{
934 			return null;
935 		}
936 
937 		return ObjectG.getDObject!(WebsocketConnection)(cast(SoupWebsocketConnection*) __p, true);
938 	}
939 
940 	/**
941 	 * Checks if @msg contains a response that would cause @session to
942 	 * redirect it to a new URL (ignoring @msg's %SOUP_MESSAGE_NO_REDIRECT
943 	 * flag, and the number of times it has already been redirected).
944 	 *
945 	 * Params:
946 	 *     msg = a #SoupMessage that has response headers
947 	 *
948 	 * Returns: whether @msg would be redirected
949 	 *
950 	 * Since: 2.38
951 	 */
952 	public bool wouldRedirect(Message msg)
953 	{
954 		return soup_session_would_redirect(soupSession, (msg is null) ? null : msg.getMessageStruct()) != 0;
955 	}
956 
957 	/**
958 	 * Emitted when the session requires authentication. If
959 	 * credentials are available call soup_auth_authenticate() on
960 	 * @auth. If these credentials fail, the signal will be
961 	 * emitted again, with @retrying set to %TRUE, which will
962 	 * continue until you return without calling
963 	 * soup_auth_authenticate() on @auth.
964 	 *
965 	 * Note that this may be emitted before @msg's body has been
966 	 * fully read.
967 	 *
968 	 * If you call soup_session_pause_message() on @msg before
969 	 * returning, then you can authenticate @auth asynchronously
970 	 * (as long as you g_object_ref() it to make sure it doesn't
971 	 * get destroyed), and then unpause @msg when you are ready
972 	 * for it to continue.
973 	 *
974 	 * Params:
975 	 *     msg = the #SoupMessage being sent
976 	 *     auth = the #SoupAuth to authenticate
977 	 *     retrying = %TRUE if this is the second (or later) attempt
978 	 */
979 	gulong addOnAuthenticate(void delegate(Message, Auth, bool, Session) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
980 	{
981 		return Signals.connect(this, "authenticate", dlg, connectFlags ^ ConnectFlags.SWAPPED);
982 	}
983 
984 	/**
985 	 * Emitted when a new connection is created. This is an
986 	 * internal signal intended only to be used for debugging
987 	 * purposes, and may go away in the future.
988 	 *
989 	 * Params:
990 	 *     connection = the connection
991 	 *
992 	 * Since: 2.30
993 	 */
994 	gulong addOnConnectionCreated(void delegate(ObjectG, Session) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
995 	{
996 		return Signals.connect(this, "connection-created", dlg, connectFlags ^ ConnectFlags.SWAPPED);
997 	}
998 
999 	/**
1000 	 * Emitted when a request is queued on @session. (Note that
1001 	 * "queued" doesn't just mean soup_session_queue_message();
1002 	 * soup_session_send_message() implicitly queues the message
1003 	 * as well.)
1004 	 *
1005 	 * When sending a request, first #SoupSession::request_queued
1006 	 * is emitted, indicating that the session has become aware of
1007 	 * the request.
1008 	 *
1009 	 * Once a connection is available to send the request on, the
1010 	 * session emits #SoupSession::request_started. Then, various
1011 	 * #SoupMessage signals are emitted as the message is
1012 	 * processed. If the message is requeued, it will emit
1013 	 * #SoupMessage::restarted, which will then be followed by
1014 	 * another #SoupSession::request_started and another set of
1015 	 * #SoupMessage signals when the message is re-sent.
1016 	 *
1017 	 * Eventually, the message will emit #SoupMessage::finished.
1018 	 * Normally, this signals the completion of message
1019 	 * processing. However, it is possible that the application
1020 	 * will requeue the message from the "finished" handler (or
1021 	 * equivalently, from the soup_session_queue_message()
1022 	 * callback). In that case, the process will loop back to
1023 	 * #SoupSession::request_started.
1024 	 *
1025 	 * Eventually, a message will reach "finished" and not be
1026 	 * requeued. At that point, the session will emit
1027 	 * #SoupSession::request_unqueued to indicate that it is done
1028 	 * with the message.
1029 	 *
1030 	 * To sum up: #SoupSession::request_queued and
1031 	 * #SoupSession::request_unqueued are guaranteed to be emitted
1032 	 * exactly once, but #SoupSession::request_started and
1033 	 * #SoupMessage::finished (and all of the other #SoupMessage
1034 	 * signals) may be invoked multiple times for a given message.
1035 	 *
1036 	 * Params:
1037 	 *     msg = the request that was queued
1038 	 *
1039 	 * Since: 2.24
1040 	 */
1041 	gulong addOnRequestQueued(void delegate(Message, Session) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
1042 	{
1043 		return Signals.connect(this, "request-queued", dlg, connectFlags ^ ConnectFlags.SWAPPED);
1044 	}
1045 
1046 	/**
1047 	 * Emitted just before a request is sent. See
1048 	 * #SoupSession::request_queued for a detailed description of
1049 	 * the message lifecycle within a session.
1050 	 *
1051 	 * Deprecated: Use #SoupMessage::starting instead.
1052 	 *
1053 	 * Params:
1054 	 *     msg = the request being sent
1055 	 *     socket = the socket the request is being sent on
1056 	 */
1057 	gulong addOnRequestStarted(void delegate(Message, SSocket, Session) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
1058 	{
1059 		return Signals.connect(this, "request-started", dlg, connectFlags ^ ConnectFlags.SWAPPED);
1060 	}
1061 
1062 	/**
1063 	 * Emitted when a request is removed from @session's queue,
1064 	 * indicating that @session is done with it. See
1065 	 * #SoupSession::request_queued for a detailed description of the
1066 	 * message lifecycle within a session.
1067 	 *
1068 	 * Params:
1069 	 *     msg = the request that was unqueued
1070 	 *
1071 	 * Since: 2.24
1072 	 */
1073 	gulong addOnRequestUnqueued(void delegate(Message, Session) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
1074 	{
1075 		return Signals.connect(this, "request-unqueued", dlg, connectFlags ^ ConnectFlags.SWAPPED);
1076 	}
1077 
1078 	/**
1079 	 * Emitted when an SSL tunnel is being created on a proxy
1080 	 * connection. This is an internal signal intended only to be
1081 	 * used for debugging purposes, and may go away in the future.
1082 	 *
1083 	 * Params:
1084 	 *     connection = the connection
1085 	 *
1086 	 * Since: 2.30
1087 	 */
1088 	gulong addOnTunneling(void delegate(ObjectG, Session) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
1089 	{
1090 		return Signals.connect(this, "tunneling", dlg, connectFlags ^ ConnectFlags.SWAPPED);
1091 	}
1092 }